<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>循环结构</title>
		<script src="../js/vue.js"></script>
		<style type="text/css">
			[v-cloak]{
				display: none;
			}
		</style>
	</head>
	<body>
		<div id="app" v-cloak>
			<!-- 1.循环数组 注意事项：循环时最好指定key 标识循环的内容 -->
			<h3 v-for="item in hobbys" v-text="item" :key="item"></h3>
			<!-- 2.带下标的循环遍历语法 两个参数，参数1：遍历的数据 参数2：下标 -->
			<h3 v-for="(item,index) in hobbys" v-text="item" :key="index"></h3>
			
			<!-- 3.遍历对象 -->
			<div v-for="user in userList" :key="user.id">
				<span v-text="user.id"></span>
				<span v-text="user.name"></span>
			</div>
		</div>
		
	</body>
	<script>
		const app = new Vue({
			el:"#app",
			data:{
				hobbys:['打游戏','敲代码','水王八'],
				userList:[
					{
						id:12,
						name:'孙尚香'
					},
					{
						id:13,
						name:'王昭君'
					},
					{
						id:123,
						name:'李元芳'
					}
					]
			}
		})
	</script>
</html>
